#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+10;
ll T,n,m,L,V,p[N],cn[N],outv,ans;
struct car
{
    ll d;
    ll v;
    ll a;
}c[N];
double getSpeed(ll x,ll ind)
{
    ll v=c[ind].v;
    ll a=c[ind].v;
    ll d=c[ind].d;
    ll v1=sqrt(v*v+2*a*(x-d));
    return v1;
}
int getNear(ll ind)
{
    ll d=c[ind].d;
    if(p[m]<d){
        return 0;
    }
    for(int i=1;i<=m;i++){
        if(p[i]>=d)return i;
    }
    return 0;
}
int main()
{
    ios::sync_with_stdio(false);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    for(int TT=1;TT<=T;TT++){
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>c[i].d>>c[i].v>>c[i].a;
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
        }
        for(int i=1;i<=n;i++){
            int v0=c[i].v,d=c[i].d,a=c[i].a;
            if(getNear(i)==0){
                for(int j=1;j<=m;j++){
                    cn[i]++;
                }
                continue;
            }
            if(a==0){
                if(v0>V&&getNear(i))outv++;
                for(int j=1;j<=m;j++){
                    cn[j]++;
                }
                continue;
            }
            if(a<0){
                if(v0<=V){
                    for(int j=1;j<=m;j++){
                        cn[j]++;
                    }
                    continue;
                }
                int ne=getNear(i);
                for(int j=1;j<=ne;j++){
                    cn[j]++;
                }
                for(int j=ne;j<=m;j++){
                    if(getSpeed(p[j],i)>V){
                        for(int x=j;x<=m;x++){
                            cn[x]++;
                        }
                        outv++;
                        break;
                    }
                }
                continue;
            }
            if(a>0){
                double xm=(V*V-v0*v0)/2/a;
                if(xm>=L){
                    for(int j=1;j<=m;j++){
                        cn[j]++;
                    }
                    continue;
                }
                int tem;
                for(int awa=1;awa<=m;awa++){
                    if(p[awa]<=xm){
                        cn[awa]++;
                    }else
                    {
                        if(tem==0){
                            tem=awa;
                        }else
                        {
                            cn[awa]++;
                        }
                    }
                }
            }
        }
        for(int awa=1;awa<=m;awa++){
            if(cn[awa]==n){
                ans++;
            }
        }
        cout<<outv<<" "<<ans<<endl;
    }
    return 0;
}
